package com.example.myspringframework.test;

import com.example.myspringframework.beans.BeansException;
import com.example.myspringframework.beans.factory.ConfigurableListableBeanFactory;
import com.example.myspringframework.beans.PropertyValue;
import com.example.myspringframework.beans.PropertyValues;
import com.example.myspringframework.beans.factory.config.BeanDefinition;
import com.example.myspringframework.beans.factory.config.BeanFactoryPostProcessor;

public class CustomBeanFactoryPostProcessor implements BeanFactoryPostProcessor {

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println("修改beanDefinition属性");
        BeanDefinition personBeanDefiniton = beanFactory.getBeanDefinition("user");
		PropertyValues propertyValues = personBeanDefiniton.getPropertyValues();
		//将person的name属性改为ivy
        PropertyValue propertyValue = propertyValues.getPropertyValue("name");
        propertyValue.setValue("liuxinyu");
    }

}
